<template>
  <div class="dashboard-container">
    admin-dashboard
    <div v-for="(client,key) in clients" :key="key">{{ client.id }}  -  {{ client.user.username }}</div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { addMessageHandler } from '@/utils/websocket'

export default {
  name: 'Dashboard',
  components: { },
  data() {
    return {
      currentRole: 'adminDashboard',
      clients: []
    }
  },
  computed: {
    ...mapGetters([
      'roles'
    ])
  },
  created() {
    if (!this.roles.includes('admin')) {
      this.currentRole = 'editorDashboard'
    }

    // 注册页面消息处理器
    addMessageHandler('hubBaseInfo', (message) => {
      console.log('页面消息处理器2', message.data.clients)
      this.clients = message.data.clients
    })
  }
}
</script>
